from flask import jsonify


# 响应工具类
class ResponseUtil:
    @staticmethod
    def success(data=None):
        response = jsonify({
            "code": 200,
            "msg": "success",
            "data": data or {}
        })
        response.headers['Content-Type'] = 'application/json; charset=utf-8'  # 强制指定编码
        return response

    @staticmethod
    def error(code, msg):
        response = jsonify({
            "code": code,
            "msg": msg,
            "data": {}
        })
        response.headers['Content-Type'] = 'application/json; charset=utf-8'  # 强制指定编码
        return response
